package cn.tiancaifan.micro.utils;

import java.io.*;

public class FileUtils {
    public static void Input2OutFile(InputStream input, String path, String filename) throws IOException {
        OutputStream output = null;
        try {
            File file = new File(path);
            if (!file.exists()){
                file.mkdirs();
            }
            File file1 = new File(path+filename);
            output = new FileOutputStream(file1);
            byte[] buf = new byte[1024];
            int bytesRead;
            while ((bytesRead = input.read(buf)) > 0) {
                output.write(buf, 0, bytesRead);
            }
        }finally {
            input.close();
            output.close();
        }
    }
}
